//https://leetcode.cn/problems/gu-piao-de-zui-da-li-run-lcof/
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        if (prices.empty())
        {
            return 0;
        }
        int ret = 0;
        int min = prices[0];
        for (auto p : prices)
        {
            if (p <= min)
            {
                min = p;
            }
            else
            {
                if (ret < (p - min))
                {
                    ret = p - min;
                }
            }
        }

        return ret;
    }
};